From caf500204f0cd52a0e1fb838029e52bafbfd072b Mon Sep 17 00:00:00 2001 From: Keir Fraser Date: Thu, 18 Mar 2010 07:44:21 +0000 Subject: [PATCH] Fixes for 21040:b64a8d2a80ad "support affinity for >64 CPUs" Signed-off-by: James (Song Wei) --- tools/libxc/xc_domain.c | 3 +-- tools/python/xen/lowlevel/xc/xc.c | 14 +++++--------- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/tools/libxc/xc_domain.c b/tools/libxc/xc_domain.c index 0329fdbf68..682c9241c1 100644 --- a/tools/libxc/xc_domain.c +++ b/tools/libxc/xc_domain.c @@ -138,8 +138,7 @@ int xc_vcpu_setaffinity(int xc_handle, int xc_vcpu_getaffinity(int xc_handle, uint32_t domid, int vcpu, - uint64_t *cpumap, - int cpusize) + uint64_t *cpumap, int cpusize) { DECLARE_DOMCTL; int ret = -1; diff --git a/tools/python/xen/lowlevel/xc/xc.c b/tools/python/xen/lowlevel/xc/xc.c index 9b1d4e253a..d41b69441c 100644 --- a/tools/python/xen/lowlevel/xc/xc.c +++ b/tools/python/xen/lowlevel/xc/xc.c @@ -220,10 +220,9 @@ static PyObject *pyxc_vcpu_setaffinity(XcObject *self, int nr_cpus, size; xc_physinfo_t info; xc_cpu_to_node_t map[1]; - uint64_t cpumap_size = sizeof(cpumap); + uint64_t cpumap_size = sizeof(*cpumap); static char *kwd_list[] = { "domid", "vcpu", "cpumap", NULL }; - if ( !PyArg_ParseTupleAndKeywords(args, kwds, "i|iO", kwd_list, &dom, &vcpu, &cpulist) ) @@ -240,7 +239,6 @@ static PyObject *pyxc_vcpu_setaffinity(XcObject *self, cpumap = malloc(cpumap_size * size); if(cpumap == NULL) return pyxc_error_to_exception(); - if ( (cpulist != NULL) && PyList_Check(cpulist) ) { @@ -251,7 +249,7 @@ static PyObject *pyxc_vcpu_setaffinity(XcObject *self, for ( i = 0; i < PyList_Size(cpulist); i++ ) { long cpu = PyInt_AsLong(PyList_GetItem(cpulist, i)); - *(cpumap + cpu / (cpumap_size * 8)) |= (uint64_t)1 << (cpu % (cpumap_size * 8)); + cpumap[cpu / (cpumap_size * 8)] |= (uint64_t)1 << (cpu % (cpumap_size * 8)); } } @@ -260,7 +258,6 @@ static PyObject *pyxc_vcpu_setaffinity(XcObject *self, free(cpumap); return pyxc_error_to_exception(); } - Py_INCREF(zero); free(cpumap); return zero; @@ -385,7 +382,7 @@ static PyObject *pyxc_vcpu_getinfo(XcObject *self, int nr_cpus, size; xc_physinfo_t pinfo = { 0 }; xc_cpu_to_node_t map[1]; - uint64_t cpumap_size = sizeof(cpumap); + uint64_t cpumap_size = sizeof(*cpumap); static char *kwd_list[] = { "domid", "vcpu", NULL }; @@ -419,16 +416,15 @@ static PyObject *pyxc_vcpu_getinfo(XcObject *self, "running", info.running, "cpu_time", info.cpu_time, "cpu", info.cpu); - cpulist = PyList_New(0); - for ( i = 0; i < size * cpumap_size * 8; i++ ) + for ( i = 0; i < nr_cpus; i++ ) { if (*(cpumap + i / (cpumap_size * 8)) & 1 ) { PyObject *pyint = PyInt_FromLong(i); PyList_Append(cpulist, pyint); Py_DECREF(pyint); } - *(cpumap + i / (cpumap_size * 8)) >>= 1; + cpumap[i / (cpumap_size * 8)] >>= 1; } PyDict_SetItemString(info_dict, "cpumap", cpulist); Py_DECREF(cpulist); -- 2.30.2